<template>
  <div>
    <h1>tom</h1>
    <input type="text" v-model="num" />
    <button @click="testEmit1">test如何触发事件</button>
  </div>
</template>

<script>
/* 测试 $on $emit 组件内部传递 */
export default {
  name: "",
  props: [""],
  data() {
    return {
      num: 0
    };
  },

  components: {},

  computed: {},

  beforeMount() {},

  mounted() {
    this.$on("eventOne", (num, num1) => {
      console.log(num);
      console.log(num1);
    });
  },

  methods: {
    testEmit1() {
      // 触发刚才绑定的$on eventOne
      //   $on绑定事件  $emit触发分发事件
      this.$emit("eventOne", this.num, 10);
    }
  },

  watch: {}
};
</script>
<style lang='' scoped>
</style>